﻿using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using Jinjia.Approve.IRepository.JJFlow;
using Jinjia.Approve.IService.JJFlow;
using Jinjia.Approve.Model.VM.JJFlow;

namespace Jinjia.Approve.Service.JJFlow
{
    /// <summary>
    /// 审批流节点流程
    /// </summary>
    public class JJFlowNodeReferenceService : IJJFlowNodeReferenceService
    {
        private readonly IFlowNodeReferenceRepository _flowNodeReferenceRepository;
        private readonly IMapper _mapper;

        public JJFlowNodeReferenceService(IFlowNodeReferenceRepository flowNodeReferenceRepository, IMapper mapper)
        {
            _flowNodeReferenceRepository = flowNodeReferenceRepository;
            _mapper = mapper;
        }
        
        public async Task<List<JJFlowNodeReferenceVM>> GetListByInstanceId(int instanceId)
        {
            var nodeReferences = await _flowNodeReferenceRepository.GetReferences(instanceId);
            return _mapper.Map<List<JJFlowNodeReferenceVM>>(nodeReferences);
        }
    }
}